package com.bd.rj.backstage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bd.rj.common.entity.Interview;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 白世俊
 * @since 2025-01-03
 */
@Mapper
public interface InterviewMapper extends BaseMapper<Interview> {
    IPage<Map> getInterviewByPageAndConditon(
            Page<Map> page,
            @Param("userId") Long userId,
            @Param("name") String name,
            @Param("status") Integer status);
    void insertInterviewRecord(Map<String,Object> recordinfo);
    @Select("select count(*) from interview where interview.pid IN(select id from post where uid = #{uid})")
    int getInterviewCount(@Param("uid") Long uid);
    double getInterviewPercentage(Long pid);
    List<Map<String,Object>> getInterviewTrend(Long uid);

    // 自定义查询方法，根据 pid 和 status 统计 interview 表中的记录数
    int countInterviewsByPidAndStatus(@Param("pid") Long pid);
}
